package fileAndIO.io;

import java.io.*;

public class FileCopySample {
    public static void main(String[] args) {
        File source = new File("C:\\Users\\83726\\Desktop\\ccc.pdf");
        File target = new File("C:\\Users\\83726\\Desktop\\cccc.pdf");
        InputStream fis = null;
        OutputStream fos = null;
        try {
            fis = new FileInputStream(source);
            fos = new FileOutputStream(target);
            byte[] bs = new byte[1024];
            int len;
            while ((len = fis.read(bs)) != -1) {
                System.out.println(len);
                fos.write(bs, 0, len);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }

}
